import service from "@/util/service";
import { id } from "element-plus/es/locale";

// 获取
export function getRoleList(){
    return service({
        url:"roles",
        method:"get"
    })
}

export function RoleDescList(){
    return service({
        url:"rights/list",
        method:"get"
    })
}

// 添加
export function addRoleList(data:{
    roleName:string,
    roleDesc:string
}){
    return service({
        url:"roles",
        method:"POST",
        data
    })
}

// 删除
export function deleteRole(id:any){
    return service({
        url:"roles/"+id,
        method:"delete"
    })
}


// 所有的权限列表
// 值 list 或 tree , list 列表显示权限, tree 树状显示权限,参数是url参数:type
export function getPowerTree(type:string){
    return service({
        url:'/rights/'+type,
        method:'get'
    })
}

// 左侧菜单权限
export function getMenus(){
    return service({
        url:'menus',
        method:'get'
    })
}

// 编辑
    export function EditRole(id:any,data:{
        roleName:string;
        roleDesc:string;
    }){
        return service({
            url:"roles/"+id,
            method:"put",
            data
        })
    }



    // 权限分配
    export function setPower(data:{id:number,rids:string}){
        return service({
        url:'roles/'+data.id+'/rights',
        method:'post',
        data
        })
    } 